package com.weetop.aklyscan.utils.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
import android.view.View;

public class AnalyzeView extends View {
    private float a = 1.0f;
    private float b = 1.0f;
    private float c = 1.0f;

    public AnalyzeView(Context context) {
        super(context);
    }

    public AnalyzeView(Context context, AttributeSet attrs) {
        super(context, attrs);

    }


    @Override
    public void draw(Canvas canvas) {
        super.draw(canvas);
        Paint p = new Paint();

        p.setColor(Color.parseColor("#10A5DD"));
        p.setAlpha(140);
        //实例化路径
        Path path = new Path();
        int w = getWidth();
        int h = getHeight();


//        Bitmap bitmapPaint = BitmapFactory.decodeResource(getResources(), R.mipmap.three_bg);
//        canvas.drawBitmap(bitmapPaint,0,0,p);

        path.moveTo(w / 2, h / 2 * (1 - a));// 此点为多边形的起点
        path.lineTo(w / 2 + w / 2 * b, h / 2 + h / 2 * b);
        path.lineTo(w / 2 * (1 - c), h / 2 + h / 2 * c);
        path.close(); // 使这些点构成封闭的多边形
        canvas.drawPath(path, p);
    }

    public void setData(float a, float b, float c) {
        this.a = a;
        this.b = b;
        this.c = c;
        postInvalidate();
    }

}
